home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / tpapi.exe / EXAMPLES / GETGROUP.PAS < prev    next >
Pascal/Delphi Source File  |  1994-01-14  |  4KB  |  113 lines

  1. {***************************************************************************}
  2. {** Program : GETGROUP                                                    **}
  3. {***************************************************************************}
  4. {** Version : 1.0             ** Started :           ** Ended :           **}
  5. {***************************************************************************}
  6. {******************************** Description ******************************}
  7. {***************************************************************************}
  8. {** Example program to list all the groups that a user is in.             **}
  9. {**                                                                       **}
  10. {**                                                                       **}
  11. {**                                                                       **}
  12. {**                                                                       **}
  13. {**                                                                       **}
  14. {**                                                                       **}
  15. {**                                                                       **}
  16. {***************************************************************************}
  17. {******************************** Information ******************************}
  18. {***************************************************************************}
  19. {** The first parameter must be a valid userid for which the information  **}
  20. {** is to be returned.                                                    **}
  21. {**                                                                       **}
  22. {**                                                                       **}
  23. {**                                                                       **}
  24. {**                                                                       **}
  25. {***************************************************************************}
  26.  
  27. {$X+}
  28.  
  29. PROGRAM GETGROUP;
  30.  
  31. USES
  32.  
  33.  nwvar,
  34.  nwerror,
  35.  nwbindry;
  36.  
  37. VAR
  38.  
  39.   BinderyFunc     : BinderyOBJ;
  40.   ObjectName      : TObjectName;
  41.   ObjectType      : OT_BinderyType;
  42.   ObjectID        : OT_BinderyID;
  43.   PropertyValue   : TPropertyValue;
  44.   AreMoreSegments : byte;
  45.   PropertyFlags   : byte;
  46.   PropertyOffset  : byte;
  47.   ObjectName1     : TObjectName;
  48.   ObjectType1     : OT_BinderyType;
  49.  
  50. BEGIN
  51.  
  52.   BinderyFunc.Init (true);
  53.   if paramcount < 1 then
  54.     begin
  55.  
  56.       writeln ('You must supply a userid as the first parameter!');
  57.       halt;
  58.  
  59.     end;
  60.  
  61.   ObjectName := BinderyFunc.UppercaseNW (paramstr (1));
  62.   ObjectType := OT_User;
  63.  
  64.   if BinderyFunc.GetBinderyObjectID (ObjectName, ObjectType, ObjectID) <> SUCCESSFUL then
  65.     begin
  66.  
  67.       writeln ('The userid that you specified does not exist!');
  68.       halt;
  69.  
  70.     end;
  71.  
  72.   repeat
  73.  
  74.   PropertyOffset := 0;
  75.   if BinderyFunc.ReadPropertyValue (ObjectName, ObjectType, 'GROUPS_I'#39'M_IN',
  76.                                     1, PropertyValue, AreMoreSegments, PropertyFlags) <> SUCCESSFUL then
  77.     begin
  78.  
  79.       writeln ('The userid does have the correct property to proceed!');
  80.       halt;
  81.  
  82.     end
  83.   else
  84.     begin
  85.  
  86.       writeln;
  87.       writeln ('Groups that user ', ObjectName, ' is a member of :');
  88.       writeln;
  89.  
  90.       repeat
  91.  
  92.         move (PropertyValue [PropertyOffSet], ObjectID, 4);
  93.         ObjectID := BinderyFunc.LongSwap (ObjectID);
  94.         if ObjectID <> 0 then
  95.           begin
  96.  
  97.             BinderyFunc.GetBinderyObjectName (ObjectID, ObjectName1, ObjectType1);
  98.             writeln (' ':2, ObjectName1);
  99.  
  100.           end;
  101.  
  102.         inc (PropertyOffset, 4);
  103.  
  104.       until ObjectID = 0;
  105.  
  106.     end;
  107.  
  108.   until AreMoreSegments = 0;
  109.  
  110.   BinderyFunc.Done;
  111.  
  112. end.
  113.